package com.oss.intercept;

import org.quartz.JobKey;

import com.fbzr.aop.AopContext;
import com.fbzr.aop.MetaObjectIntercept;
import com.fbzr.common.plugin.quartz.QuartzPlugin;

public class NoticeIntercept extends MetaObjectIntercept {

	@Override
	public String addBefore(AopContext ac) throws Exception {
		String content = ac.record.getStr("content");
		content = content.replaceAll("src=\"/ueditor/upload/image/", "src=\"http://139.196.254.85/img/ueditor/upload/image/");
		ac.record.set("content",content);
		return super.addBefore(ac);
	}

	@Override
	public String updateBefore(AopContext ac) throws Exception {
		String content = ac.record.getStr("content");
		content = content.replaceAll("src=\"/ueditor/upload/image/", "src=\"http://139.196.254.85/img/ueditor/upload/image/");
		ac.record.set("content",content);
		return super.updateBefore(ac);
	}

	@Override
	public String addAfter(AopContext ac) throws Exception {
		JobKey jobKey = JobKey.jobKey("com.oss.job.EverySecondJob", "com.oss.job.EverySecondJob");
		QuartzPlugin.scheduler.triggerJob(jobKey);
		return super.addAfter(ac);
	}

	@Override
	public String updateAfter(AopContext ac) throws Exception {
		JobKey jobKey = JobKey.jobKey("com.oss.job.EverySecondJob", "com.oss.job.EverySecondJob");
		QuartzPlugin.scheduler.triggerJob(jobKey);
		return super.updateAfter(ac);
	}

}
